

#import "ViewController.h"

#import <AMapFoundationKit/AMapFoundationKit.h>

#import "CustomTurnInfoViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    UIButton * button = [UIButton buttonWithType:(UIButtonTypeCustom)];
    button.frame = CGRectMake(10, 65, 120, 40);
    
    //button.backgroundColor = [UIColor whiteColor];
    
    button.layer.borderWidth = 1;
    button.layer.masksToBounds = YES;
    button.layer.borderColor = [UIColor blueColor].CGColor;
    
    button.layer.cornerRadius = 5;
    [button setTitle:@"选择终点位置" forState:(UIControlStateNormal)];
    [button setTitleColor:[UIColor blueColor] forState:(UIControlStateNormal)];
    [button addTarget:self action:@selector(clickBtnFunction) forControlEvents:(UIControlEventTouchUpInside)];
    [button setTitleColor:[UIColor lightGrayColor] forState:(UIControlStateHighlighted)];
    [self.view addSubview:button];
    
}

-(void)pushToNaviMapViewWithLat:(NSString *)lat andLon:(NSString *)lon
{
    CustomTurnInfoViewController * vc = [[CustomTurnInfoViewController alloc]init];
    vc.endLon = lon;
    vc.endLat = lat;
    [self.navigationController pushViewController:vc animated:YES];
    
}

-(void)clickBtnFunction
{
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"温馨息提示" message:@"请选择终点位置" preferredStyle:UIAlertControllerStyleAlert];
    
    [alert addAction:[UIAlertAction actionWithTitle:@"茶光村" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
        //        获得终点坐标位置，传入导航页面。
        
        NSString * lon = [NSString stringWithFormat:@"%f",113.959832];
        
        NSString * lat = [NSString stringWithFormat:@"%f",22.572537];
        
        [self pushToNaviMapViewWithLat:lat andLon:lon];
        
    }]];
    
    [alert addAction:[UIAlertAction actionWithTitle:@"南联路" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
        //        获得终点坐标位置，传入导航页面。
        
        //        114.265579,22.718802
        
        NSString * lon = [NSString stringWithFormat:@"%f",114.265579];
        
        NSString * lat = [NSString stringWithFormat:@"%f",22.718802];
        
        [self pushToNaviMapViewWithLat:lat andLon:lon];
        
        
    }]];
    
    
    [alert addAction:[UIAlertAction actionWithTitle:@"展涛科技大厦" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
        //        获得终点坐标位置，传入导航页面。
        //        114.038072,22.639641
        
        NSString * lon = [NSString stringWithFormat:@"%f",114.038072];
        
        NSString * lat = [NSString stringWithFormat:@"%f",22.639641];
        
        [self pushToNaviMapViewWithLat:lat andLon:lon];
        
        
    }]];
    
    [self presentViewController:alert animated:YES completion:nil];

}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
